--       _________ __                 __                               
--      /   _____//  |_____________ _/  |______     ____  __ __  ______
--      \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
--      /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \ 
--     /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
--             \/                  \/          \//_____/            \/ 
--  ______________________                           ______________________
--			  T H E   W A R   B E G I N S
--	   Stratagus - A free fantasy real time strategy game engine
--      cheats.lua - Cheat codes
--
--      (c) Copyright 2005 by David Stone

--      This program is free software; you can redistribute it and/or modify
--      it under the terms of the GNU General Public License as published by
--      the Free Software Foundation; either version 2 of the License, or
--      (at your option) any later version.
--
--      This program is distributed in the hope that it will be useful,
--      but WITHOUT ANY WARRANTY; without even the implied warranty of
--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--      GNU General Public License for more details.
--  
--      You should have received a copy of the GNU General Public License
--      along with this program; if not, write to the Free Software
--      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------

speedcheat = false
godcheat = false

function HandleCheats(str)
	local resources = { "ipc" }

	if (str == "money") then
		for i = 1,table.getn(resources) do
			SetPlayerData(GetThisPlayer(), "Resources", resources[i],
			GetPlayerData(GetThisPlayer(), "Resources", resources[i]) + 10000)
		end
		AddMessage("Aargh! Who took my money?")

	elseif (str == "on screen") then
		RevealMap()

	elseif (str == "go away") then
		SetFogOfWar(false)

	elseif (str == "i'm bored") then
		for i = 1,table.getn(resources) do
			SetSpeedResourcesHarvest(resources[i], 10)
			SetSpeedResourcesReturn(resources[i], 10)
		end
		SetSpeedBuild(10)
		SetSpeedTrain(10)
		SetSpeedUpgrade(10)
		SetSpeedResearch(10)
		AddMessage("Is this fast enough?")

	elseif (str == "Normal speed.") then
		for i = 1,table.getn(resources) do
			SetSpeedResourcesHarvest(resources[i], 1)
			SetSpeedResourcesReturn(resources[i], 1)
		end
		SetSpeedBuild(1)
		SetSpeedTrain(1)
		SetSpeedUpgrade(1)
		SetSpeedResearch(1)
		AddMessage("NORMAL SPEED")

	elseif (str == "I win") then
		if (speedcheat) then
			speedcheat = false
			for i = 1,table.getn(resources) do
				SetSpeedResourcesHarvest(resources[i], 1)
				SetSpeedResourcesReturn(resources[i], 1)
			end
			SetSpeedBuild(1)
			SetSpeedTrain(1)
			SetSpeedUpgrade(1)
			SetSpeedResearch(1)
			AddMessage("You will lose!")
		else
			speedcheat = true
			for i = 1,table.getn(resources) do
				SetSpeedResourcesHarvest(resources[i], 10)
				SetSpeedResourcesReturn(resources[i], 10)
			end
			SetSpeedBuild(10)
			SetSpeedTrain(10)
			SetSpeedUpgrade(10)
			SetSpeedResearch(10)
			for i = 1,table.getn(resources) do
				SetPlayerData(GetThisPlayer(), "Resources", resources[i],
				GetPlayerData(GetThisPlayer(), "Resources", resources[i]) + 100000)
			end
			AddMessage("You will win!")
		end

	elseif (str == "42") then
		ActionVictory()

	elseif (str == "41") then
		ActionDefeat()

	elseif (str == "I wish I was good") then
		if (godcheat) then
			godcheat = false
			SetGodMode(false)
			AddMessage("I feel I am weak.")
		else
			godcheat = true
			SetGodMode(true)
			AddMessage("We will kill all in our path.")

		end

	else
		return false
	end
	return true
end
